//
//  LotteryManager.m
//  CaiPiao
//
//  Created by apple on 2018/5/15.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "LotteryManager.h"

@implementation LotteryManager

+(LotteryManager*)sharedManager{
    static LotteryManager* manager;
    static dispatch_once_t onceT;
    dispatch_once(&onceT, ^{
        manager = [[LotteryManager alloc] init];
    });
    return manager;
}




-(void)getLotteryListActionWithCallBack:(void(^)(BOOL load,NSDictionary* resObj))callBack{
    NSString* paramsString = @"{\"SFC\":\"1\"}";
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]init];
    [manager GET:@"https://data.cp.lovedou.com/Handler.ashx" parameters:@{@"action":@"600",@"params":paramsString} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"%@",task.response.URL);
        if (callBack) {
            callBack(YES,responseObject);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (callBack) {
            callBack(NO,nil);
        }
    }];
}


//足球历史开奖列表 Action 606
//篮球历史开奖列表 Action 607
-(void)getSMGListWithIssueName:(NSString*)IssueName andAction:(NSString*)actionID andCallBack:(void(^)(BOOL load,NSDictionary* resObj))callBack{
    NSString* paramsString = [NSString stringWithFormat:@"{\"IssueName\":\"%@\",\"IsOpen\":\"1\"}",IssueName];
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]init];
    [manager GET:@"https://data.cp.lovedou.com/Handler.ashx" parameters:@{@"action":actionID,@"params":paramsString} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"%@",task.response.URL);
        
        if (callBack) {
            callBack(YES,responseObject);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (callBack) {
            callBack(NO,nil);
        }
    }];
}

//历史开奖 action 602
//竞技类开奖期数 action 205
-(void)getListWithLotteryID:(NSString*)lotteryID andActionID:(NSString*)actionID andCallBack:(void(^)(BOOL load,NSDictionary* resObj))callBack{
    NSString* paramsString = [NSString stringWithFormat:@"{\"LotteryID\":\"%@\"}",lotteryID];
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]init];
    [manager GET:@"https://data.cp.lovedou.com/Handler.ashx" parameters:@{@"action":actionID,@"params":paramsString} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"%@",task.response.URL);
        
        if (callBack) {
            callBack(YES,responseObject);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (callBack) {
            callBack(NO,nil);
        }
    }];
}


//中奖详情
//双色球，福彩，排列三,大乐透：601
-(void)getLotteryDetailWithissueID:(NSString*)IssueID andActionID:(NSString*)actionID andCallBack:(void(^)(BOOL load,NSDictionary* resObj))callBack{
    NSString* paramsString = [NSString stringWithFormat:@"{\"IssueID\":\"%@\"}",IssueID];
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]init];
    [manager GET:@"https://data.cp.lovedou.com/Handler.ashx" parameters:@{@"action":actionID,@"params":paramsString} progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"%@",task.response.URL);
        
        if (callBack) {
            callBack(YES,responseObject);
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (callBack) {
            callBack(NO,nil);
        }
    }];
}



@end
